define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    return {
        index: function () {
            Table.api.init({
                extend: {
                    index_url: 'vv/bill/index' + location.search,
                    add_url  : 'vv/bill/add',
                    edit_url : 'vv/bill/edit',
                    del_url  : 'vv/bill/del',
                    multi_url: 'vv/bill/mul',
                    table    : 'bill'
                }
            });
            const table = $("#table")
            table.bootstrapTable({
                url    : $.fn.bootstrapTable.defaults.extend.index_url,
                pk     : 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: 'ID'},
                        {field: 'finish_is', title: '是否已处理', searchList: {0: '否', 1: '是'}, formatter: Table.api.formatter.normal},
                        {field: 'create_at', title: '申请时间', formatter: Table.api.formatter.datetime, operate: false},
                        {field: 'shop.shopname', title: '开票商', operate: false},
                        {field: 'type', title: '类型', searchList: {1: '电子普通发票', 2: '专用发票'}, formatter: Table.api.formatter.normal},
                        {field: 'title', title: '发票抬头', searchList: {1: '个人', 2: '单位'}, formatter: Table.api.formatter.normal},
                        {field: 'name', title: '个人或单位名称'},
                        {field: 'sn', title: '纳税识别号'},
                        {field: 'content', title: '发票内容'},
                        {field: 'mobile', title: '收票人手机'},
                        {field: 'email', title: '收票人邮箱'},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            })
            Table.api.bindevent(table)
        },
        add  : function () {
            Form.api.bindevent($("form[role=form]"))
        },
        edit : function () {
            Form.api.bindevent($("form[role=form]"))
        }
    }
})